﻿@{
    Layout = "~/Views/Shared/_LayoutMain.cshtml";
}
<div id="dg"></div>
<div id="where" style="padding: 5px 5px;">
    <a href="javascript:Add()" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true">添加</a>
    <a href="javascript:Remove()" class="easyui-linkbutton" data-options="iconCls:'icon-cancel',plain:true">删除</a>
    <a href="javascript:Edit()" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true">编辑</a>
    类型名称：<input type="text" id="typeName" style="width: 100px" />
    <a href="javascript:Query()" class="easyui-linkbutton">查询</a>
</div>
<script type="text/javascript">
    $(function () {
        $('#dg').datagrid({
            url: '/Consume/GetConsumeTypeList',
            title: '消费类型列表',
            idField: 'id',
            border: false,
            fit: true,
            method: 'post',
            toolbar: "#where",
            pagination: true,
            pageSize: 50,
            pageNumber: 1,
            pageList: [50, 30, 20],
            columns: [[
                { field: 'id', title: '主键', checkbox: true },
                { field: 'ct_TypeName', title: '消费类型名称' },
                { field: 'ct_TypeAbbreviation', title: '简称' },
                { field: 'ParenetName', title: '父级名称' },
                { field: 'ct_Remark', title: '备注' }
            ]]
        });
    })
    function Query() {
        $('#dg').datagrid('reload', {
            typeName: $("#typeName").val()
        });
    }
    function Add() {
        window.parent.addTab('添加消费记录分类', '/Consume/AEConsumeType');
    }
    function Remove() {
        $.messager.confirm("警告", "你真的要删除吗", function (r) {
            if (r) {
                var rows = $('#dg').datagrid('getSelections');
                var ids = new Array();
                for (var i = 0; i < rows.length; i++) {
                    ids.push(rows[i]["id"]);
                }
                if (ids.length == 0) {
                    $.messager.show({
                        title: '提示',
                        msg: '请选择你要删除的记录行',
                        timeout: 5000,
                        showType: 'slide'
                    });
                    return;
                }
                var _ids = ids.join(",");
                $.ajax({
                    type: "POST",
                    url: "/Consume/DeleteConsumeType",
                    data: { ids: _ids },
                    success: function (msg) {
                        if (msg == "success") {
                            S_success();
                        } else {
                            E_error();
                        }
                    }
                });
            }
        })
    }
</script>

